<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title></title>
    <script src="js/jquery-3.6.0.js"></script>
</head>
<body>
    <h1>修改电池信息页面</h1>
    <form method="get" action="PowerBatteryUpdate?id=${sessionScope.powerBattery.id}">
        <table border="1px">
            <tr>
                <th>车辆类型</th>
                <th>
                    <input type="text" name="carName" id="carName" value="${sessionScope.powerBattery.carName}">
                </th>
            </tr>
            <tr>
                <th>所属城市</th>
                <th>
                    <input type="text" name="cityName" id="cityName" value="${sessionScope.powerBattery.cityName}">
                </th>
            </tr>
            <tr>
                <th>使用单位</th>
                <th>
                    <input type="text" name="userName" id="userName" value="${sessionScope.powerBattery.userName}">
                </th>
            </tr>
            <tr>
                <th>压差报警值</th>
                <th>
                    <input type="text" name="pressureValue" id="pressureValue" value="${sessionScope.powerBattery.pressureValue}">
                </th>
            </tr>
            <tr>
                <th>报警时间</th>
                <th>
                    <input type="text" name="time" id="time" value="${sessionScope.powerBattery.time}">
                </th>
            </tr>
            <tr>
                <th>操作</th>
                <th>
                    <input type="submit" value="修改">
                </th>
            </tr>
        </table>
    </form>
</body>
<script>
    $("form").submit(function (){
        if ($("#carName").val() == "" || $("cityName").val() == "" || $("userName") == ""){
            alert("请填写完整的信息!")
            return false;
        }
        if (isNaN($("#pressureValue").val())){
            alert("压差报警值必须是数值类型")
            return false;
        }
        var date = /^\d{4}-\d{1,2}-\d{1,2}$/;
        if ($("time") != date){
            alert("时间格式不正确")
            return false;
        }
    })
</script>
</html>
